Skip to contentSkip to conversation

Change in openvpn[master]: win: refactor get_windows_version()

Openvpn-devel In review stipa (Code Review) 2 participants 8 messages Apr 18, 2025 – May 5, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1744981598000.I39d660ebeec76280e4d4357192b74bf2c0980615@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/944?usp=email

to review the following change.

Change subject: win: refactor get_windows_version()
......................................................................

win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater)"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631"

Remove "pre-Win7" checks in a few places.

For IV_PLAT_VER, we now provide only the version number without binary architecture info. Previously:

IV_PLAT_VER=10.0,_amd64_executable

Now:

IV_PLAT_VER=10.0.22631

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

---
M src/openvpn/tun.c
M src/openvpn/win32.c
M src/openvpn/win32.h

3 files changed, 49 insertions(+), 93 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/44/944/1

src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +38 -81

137 lines not on this page · raw message

src/openvpn/win32.h +7 -4
index 081beeb..d663586 100644
@@ -301,11 +301,14 @@
 
 int win32_version_info(void);
 
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string, optionally with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @param add_exec_info Whether to include architecture details.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc, bool add_exec_info);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/944?usp=email

to look at the new patch set (#2).

Change subject: win: refactor get_windows_version()
......................................................................

win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

---
M src/openvpn/options.c
M src/openvpn/ssl.c
M src/openvpn/tun.c
M src/openvpn/win32.c
M src/openvpn/win32.h

5 files changed, 36 insertions(+), 86 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/44/944/2

src/openvpn/options.c +1 -1
index 96119c4..c523649 100644
@@ -4846,7 +4846,7 @@
 show_windows_version(const unsigned int flags)
 {
     struct gc_arena gc = gc_new();
-    msg(flags, "Windows version %s", win32_version_string(&gc, true));
+    msg(flags, "Windows version: %s", win32_version_string(&gc));
     gc_free(&gc);
 }
 #endif
src/openvpn/ssl.c +1 -1
index 23f6423..fd299ef 100644
@@ -2060,7 +2060,7 @@
             }
             buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() );
 #if defined(_WIN32)
-            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false));
+            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc));
 #else
             struct utsname u;
             uname(&u);
src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +24 -72

118 lines not on this page · raw message

src/openvpn/win32.h +6 -4
index 081beeb..bb934b7 100644
@@ -301,11 +301,13 @@
 
 int win32_version_info(void);
 
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/944?usp=email

to look at the new patch set (#3).

Change subject: win: refactor get_windows_version()
......................................................................

win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

---
M src/openvpn/options.c
M src/openvpn/ssl.c
M src/openvpn/tun.c
M src/openvpn/win32.c
M src/openvpn/win32.h

5 files changed, 36 insertions(+), 95 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/44/944/3

src/openvpn/options.c +1 -1
index 96119c4..c523649 100644
@@ -4846,7 +4846,7 @@
 show_windows_version(const unsigned int flags)
 {
     struct gc_arena gc = gc_new();
-    msg(flags, "Windows version %s", win32_version_string(&gc, true));
+    msg(flags, "Windows version: %s", win32_version_string(&gc));
     gc_free(&gc);
 }
 #endif
src/openvpn/ssl.c +1 -1
index 23f6423..fd299ef 100644
@@ -2060,7 +2060,7 @@
             }
             buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() );
 #if defined(_WIN32)
-            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false));
+            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc));
 #else
             struct utsname u;
             uname(&u);
src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +24 -72

118 lines not on this page · raw message

src/openvpn/win32.h +6 -13
index 081beeb..685898c 100644
@@ -292,20 +292,13 @@
 
 bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel);
 
-#define WIN_XP    0
-#define WIN_VISTA 1
-#define WIN_7     2
-#define WIN_8     3
-#define WIN_8_1   4
-#define WIN_10    5
-
-int win32_version_info(void);
-
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/944?usp=email )

Change subject: win: refactor get_windows_version()
......................................................................

Patch Set 3: Code-Review+2

(1 comment)

Patchset:

PS3:
After some discussion on IRC - RtlGetVersion() needs to be called that way if used from userland. Windows documentation points to GetVersionEx() which provides different information and is not useful to us.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Mon, 05 May 2025 12:26:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#5 lore raw

PATCH v3 1/1 win: refactor get_windows_version()

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/944
This mail reflects revision 3 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/options.c +1 -1
index 96119c4..c523649 100644
@@ -4846,7 +4846,7 @@
 show_windows_version(const unsigned int flags)
 {
     struct gc_arena gc = gc_new();
-    msg(flags, "Windows version %s", win32_version_string(&gc, true));
+    msg(flags, "Windows version: %s", win32_version_string(&gc));
     gc_free(&gc);
 }
 #endif
src/openvpn/ssl.c +1 -1
index 23f6423..fd299ef 100644
@@ -2060,7 +2060,7 @@
             }
             buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() );
 #if defined(_WIN32)
-            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false));
+            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc));
 #else
             struct utsname u;
             uname(&u);
src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +24 -72

118 lines not on this page · raw message

src/openvpn/win32.h +6 -13
index 081beeb..685898c 100644
@@ -292,20 +292,13 @@
 
 bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel);
 
-#define WIN_XP    0
-#define WIN_VISTA 1
-#define WIN_7     2
-#define WIN_8     3
-#define WIN_8_1   4
-#define WIN_10    5
-
-int win32_version_info(void);
-
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: win: refactor get_windows_version()

I have mildly tested this (mingw-compiled 32/64 bit binaries and tried to find VMs to run them on, but most of this failed due to this or that or windows in general). I did test Win7/i386 (32bit binaries on 7/64), Win10/amd64, Win11/amd64, and the result was what I expected.

Now, with Microsoft being as silly as they are, we could just hardcode the first two digits - all versions are "10.0" now, with a build number 3rd... but hey, maybe KI will make them return to useful versioning one day, and then our use of the API stands ready!

Your patch has been applied to the master branch.

commit 45a4f4e5f6c3552a27a8064ab6a857c465efc2f0

Author: Lev Stipakov
Date:   Mon May 5 14:27:06 2025 +0200
     win: refactor get_windows_version()

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg31566.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#7 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#4) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/944?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: win: refactor get_windows_version()
......................................................................

win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31566.html

---
M src/openvpn/options.c
M src/openvpn/ssl.c
M src/openvpn/tun.c
M src/openvpn/win32.c
M src/openvpn/win32.h

5 files changed, 36 insertions(+), 95 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/44/944/4

src/openvpn/options.c +1 -1
index 8c41dec..02970a7 100644
@@ -4847,7 +4847,7 @@
 show_windows_version(const unsigned int flags)
 {
     struct gc_arena gc = gc_new();
-    msg(flags, "Windows version %s", win32_version_string(&gc, true));
+    msg(flags, "Windows version: %s", win32_version_string(&gc));
     gc_free(&gc);
 }
 #endif
src/openvpn/ssl.c +1 -1
index 23f6423..fd299ef 100644
@@ -2060,7 +2060,7 @@
             }
             buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() );
 #if defined(_WIN32)
-            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false));
+            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc));
 #else
             struct utsname u;
             uname(&u);
src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +24 -72

118 lines not on this page · raw message

src/openvpn/win32.h +6 -13
index 081beeb..685898c 100644
@@ -292,20 +292,13 @@
 
 bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel);
 
-#define WIN_XP    0
-#define WIN_VISTA 1
-#define WIN_7     2
-#define WIN_8     3
-#define WIN_8_1   4
-#define WIN_10    5
-
-int win32_version_info(void);
-
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#8 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/944?usp=email )

Change subject: win: refactor get_windows_version()
......................................................................

win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer. Instead of displaying:

"Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

"Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id I39d660ebeec76280e4d4357192b74bf2c0980615

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31566.html

---
M src/openvpn/options.c
M src/openvpn/ssl.c
M src/openvpn/tun.c
M src/openvpn/win32.c
M src/openvpn/win32.h

5 files changed, 36 insertions(+), 95 deletions(-)
src/openvpn/options.c +1 -1
index 8c41dec..02970a7 100644
@@ -4847,7 +4847,7 @@
 show_windows_version(const unsigned int flags)
 {
     struct gc_arena gc = gc_new();
-    msg(flags, "Windows version %s", win32_version_string(&gc, true));
+    msg(flags, "Windows version: %s", win32_version_string(&gc));
     gc_free(&gc);
 }
 #endif
src/openvpn/ssl.c +1 -1
index 23f6423..fd299ef 100644
@@ -2060,7 +2060,7 @@
             }
             buf_printf(&out, "IV_SSL=%s\n", get_ssl_library_version() );
 #if defined(_WIN32)
-            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc, false));
+            buf_printf(&out, "IV_PLAT_VER=%s\n", win32_version_string(&gc));
 #else
             struct utsname u;
             uname(&u);
src/openvpn/tun.c +4 -8
index 4f7de6c..5186afa 100644
@@ -5428,11 +5428,8 @@
                     NETSH_PATH_SUFFIX, adapter_index,
                     print_in6_addr(addr_list[i], 0, &gc));
 
-        /* disable slow address validation on Windows 7 and higher */
-        if (win32_version_info() >= WIN_7)
-        {
-            argv_printf_cat(&argv, "%s", "validate=no");
-        }
+        /* disable slow address validation */
+        argv_printf_cat(&argv, "%s", "validate=no");
 
         /* Treat errors while adding as non-fatal as we do not check for duplicates */
         netsh_command(&argv, 1, (i==0) ? M_FATAL : M_NONFATAL);
@@ -5498,9 +5495,8 @@
                             adapter_index,
                             print_in_addr_t(addr_list[i], 0, &gc));
 
-                /* disable slow address validation on Windows 7 and higher */
-                /* only for DNS */
-                if (is_dns && win32_version_info() >= WIN_7)
+                /* disable slow address validation for DNS */
+                if (is_dns)
                 {
                     argv_printf_cat(&argv, "%s", "validate=no");
                 }
src/openvpn/win32.c +24 -72

118 lines not on this page · raw message

src/openvpn/win32.h +6 -13
index 081beeb..685898c 100644
@@ -292,20 +292,13 @@
 
 bool win_wfp_uninit(const NET_IFINDEX index, const HANDLE msg_channel);
 
-#define WIN_XP    0
-#define WIN_VISTA 1
-#define WIN_7     2
-#define WIN_8     3
-#define WIN_8_1   4
-#define WIN_10    5
-
-int win32_version_info(void);
-
-/*
- * String representation of Windows version number and name, see
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
+/**
+ * @brief Get Windows version string with architecture info.
+ *
+ * @param gc gc arena to allocate string.
+ * @return Version string, or "N/A" on failure.
  */
-const char *win32_version_string(struct gc_arena *gc, bool add_name);
+const char *win32_version_string(struct gc_arena *gc);
 
 /*
  * Send the |size| bytes in buffer |data| to the interactive service |pipe|

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/944?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Gerrit-Change-Number: 944
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged